package cn.demo.tools;

import org.apache.http.HttpHost;
import org.elasticsearch.client.RestClient;
import org.elasticsearch.client.RestClientBuilder;
import org.elasticsearch.client.RestHighLevelClient;

import java.io.Serializable;

public class EsClient implements Serializable {



    public static RestHighLevelClient getClient(){
        //1. 创建和服务器的连接
        HttpHost httpHost = new HttpHost("192.168.189.200", 9200);
        //2. 创建RestClient对象
        RestClientBuilder builder = RestClient.builder(httpHost);
        //3. 创建返回可以使用的连接对象
        return new RestHighLevelClient(builder);
    }

}
